import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from "vuex-persistedstate"
import router from '@/router'
// import SecureLS from "secure-ls"
// const ls = new SecureLS({ isCompression: false })

Vue.use(Vuex)

export default new Vuex.Store({
    state: {
        token: "",
        avatar: "",
        username: "",
        buttons: [],
        menu:[],
		isFullscreen: false
    },
    mutations: {
        login(state, payload) {
            state.token = payload.token;
        },
        logout(state) {
            state.token = "";
            router.replace('/login')
        },
        setAdminInfo(state, payload) {
            state.avatar = payload.avatar;
            state.username = payload.username;
        },
        setButtons(state, payload) {
            state.buttons = payload.filter(item=>item.name!='hidden');
        },
        SET_MENU(state,payload){
            state.menu = payload
        },
		toggleFullscreen(state, payload) {
		    state.isFullscreen = payload;
		}
    },
    actions: {
        setMenu(ctx,payload){
            ctx.commit('SET_MENU',payload)
        }
    },
    modules: {
        
    },
    plugins: [
        createPersistedState()
    ]
})
